package com.emergency.direct.controller;

import com.emergency.direct.service.PlanService;
import com.emergency.base.domain.Plan;
import com.emergency.common.entity.Result;
import com.emergency.common.entity.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by lijie on 2019/10/21.
 */
@RestController
@RequestMapping("/plan")
@Api(value="方案计划类",description = "方案计划制定，任务拟制、最优方案获取、任务下达")
public class PlanController {

    @Autowired
    private PlanService planService;

    @ApiOperation(value = "计划拟制接口" ,  notes="按照救援任务生成制定计划")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Plan", value = "计划文件", required = true, paramType = "Plan"),
    })
    @RequestMapping(value = "protocol",method = RequestMethod.POST)
    public Result protocol(@RequestBody Plan plan){
        Long planId=planService.protocolPlan(plan);
        return new Result(true, StatusCode.OK,  "拟制成功", planId);
    }

    @ApiOperation(value = "计划查询接口" ,  notes="计划查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "planId", value = "计划文件Id", required = true, paramType = "Long"),
    })
    @RequestMapping(value = "/info/get",method = RequestMethod.GET)
    public Result get(@RequestParam Long planId){
        Plan plan=planService.getPlanInfo(planId);
        return new Result(true, StatusCode.OK,  "拟制成功", planId);
    }
}
